# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=py3-impacket
_pkgname=impacket
pkgver=0.12.0
pkgrel=0
pkgdesc="Collection of Python3 classes providing access to network packets"
url="https://github.com/SecureAuthCorp/impacket"
arch="noarch"
license="Apache-2.0"
depends="
	py3-asn1
	py3-chardet
	py3-flask
	py3-future
	py3-ldap3
	py3-openssl
	py3-pycryptodomex
	py3-six
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz
	version.patch
	"
builddir="$srcdir"/$_pkgname-$pkgver

replaces="py-impacket" # Backwards compatibility
provides="py-impacket=$pkgver-r$pkgrel" # Backwards compatibility

# secfixes:
#   0.9.23-r0:
#     - CVE-2021-31800

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest -m 'not remote'
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	rm -r "$pkgdir"/usr/share/doc # LICENSE and README.md
	# "examples" but imported for cli apps
	# rm -r "$pkgdir"/usr/lib/python*/site-packages/impacket/examples
}

sha512sums="
48db5e2973cebc87a84118f2d83202f9583f45b4294e7b17c49da32bd6aedcf4e704447dd9d87e03f754c3947a9759a39624e44c5849718daae9e96b04f9aeb0  impacket-0.12.0.tar.gz
cc3e4ab6de1cf5fdb548bc32da84bfda6284b43b0d01f67a65398dfaef0faf0ad03327ed31b5c3abd553e59c0accda9ef783043908fe23560461d4d4aff33627  version.patch
"
